package com.hqbzl.c1;

import lombok.extern.slf4j.Slf4j;

import java.sql.Time;
import java.util.concurrent.TimeUnit;

@Slf4j
public class TestThreadActive {
    public static void main(String[] args) {
        final Object O1 = new Object();
        final Object O2 = new Object();
        final Thread t1 = new Thread(() -> {
            synchronized (O1) {
                try {
                    log.debug("t1");
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (O2) {

                }
            }
        }, "T1");
        final Thread t2 = new Thread(() -> {
            synchronized (O2) {
                synchronized (O1) {
                    log.debug("t2");
                }
            }
        }, "T2");
        t1.start();
        t2.start();
    }
}
